@extends("admin.frame_layout")
<?php $top_selected = "工作台";
if ($flag == 0) {
    $page_menu = "在售商品列表";
} elseif ($flag == 1) {
    $page_menu = "下架商品列表";
}
?>

@section('content')
    <div class="rightinfo">
        <table class="tablelist">
            <thead>
            <tr>
                <th width="70px">操作</th>
                <th width="100px;">缩略图</th>
                <th width="100px;">商品ID</th>
                <th width="80px;">商品编号</th>
                <th>商品名称</th>
                <th>会员价格</th>
                <th>金卡价格</th>
                <th>库存</th>
                <th>添加时间</th>
            </tr>
            </thead>
            <tbody>
            @foreach($list as $product)
                <tr>
                    <td class="act" bind="#{{$product->id}}">
                        <img src="{{asset('admin/imgs/t05.png')}}"/>菜单
                        <ul id="{{$product->id}}">
                            <li>
                                <a href="{{route('admin.product',['pro'=>$product->id])}}">
                                    编辑商品
                                </a>
                            </li>
                            @if($product->status == \App\Models\MProduct::$STATUS_SALE)
                                <li>
                                    <a onclick="return openOkDlg('{{route('admin.product.status',
                                        ['flag'=>\App\Models\MProduct::$STATUS_DOWN,
                                        'id'=>$product->id])}}')">
                                        下架商品（停止购买）
                                    </a>
                                </li>
                            @elseif($product->status == \App\Models\MProduct::$STATUS_DOWN)
                                <li>
                                    <a onclick="return openOkDlg('{{route('admin.product.status',
                                        ['flag'=>\App\Models\MProduct::$STATUS_SALE,
                                        'id'=>$product->id])}}')">
                                        上架商品（开启购买）
                                    </a>
                                </li>
                            @endif
                        </ul>
                    </td>
                    <td class="imgtd">
                        <img style="margin-top: 10px;"
                             src="{{asset($product->img)}}" width="50"/>
                    </td>
                    <td>{{$product->id}}</td>
                    <td>{{$product->no}}</td>
                    <td>{{$product->title}}</td>
                    <td>￥{{$product->p1}}</td>
                    <td>￥{{$product->p2}}</td>
                    <td>{{$product->num}}</td>
                    <td>{{date('Y-m-d H:i:s',$product->time)}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
        @include('admin.coms.fenye')
    </div>
    @include('admin.coms.dialog')
@endsection
@section('footer')
    <script type="text/javascript">
        $('.imgtable tbody tr:odd').addClass('odd');
        $(".tablelist .act").hover(function () {
            $($(this).attr("bind")).show();
        }, function () {
            $($(this).attr("bind")).hide();
        });
    </script>
@endsection
